import { Body, Controller, Get, Param, Post, Put, Request } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { UserService } from './user.service';
import { CURRENT_USER } from 'src/core/contants';
import { UpdateUserDto } from './user.dto';

@ApiTags('用户管理')
@ApiBearerAuth()
@Controller('user')
export class UserController {
  constructor(private userService: UserService) {}

  @Get('info')
  @ApiOperation({ summary: '获取用户详细' })
  async getUserInfo(@Request() req) {
    return await this.userService.findOne(req[CURRENT_USER].uid);
  }

  @Post('update')
  @ApiOperation({ summary: '更新用户信息' })
  async updateUserInfo(@Body() userInfo: UpdateUserDto) {
    return await this.userService.update(userInfo);
  }

  // @Get('role/student/:id')
  // @ApiOperation({ summary: '更新为学生角色' })
  // async updateUserRole(@Param('id') id: string) {
  //   return await this.userService.switchRoleStudent(id);
  // }

  // @Put('role/company')
  // @ApiOperation({ summary: '切换为企业角色' })
  // async switchRoleCompany(@Body() updateRoleCompanyDto: UpdateRoleCompanyDto) {
  //   return await this.userService.updateRoleCompany(updateRoleCompanyDto);
  // }
}
